<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <li>01</li>
    <li>02</li>
    <li>03</li>
    <li>04</li>
    <li>05</li>
    <li>06</li>
    <li>07</li>
    <li>08</li>
    <li>09</li>
    <li>10</li>
</body>
<script>
    // 扩展运算符 (...)  => 给数组/伪数组 字符串  对象使用  Set(得到去重后的数组)  Map(键值对形成二维数组)


    // 1. 将一个数组转为用逗号分隔的参数序列。

    var list = [1, 4, 7, 2, 5, 8, 3, 6, 9];

    console.log(...list); // ...list =>  1, 4, 7, 2, 5, 8, 3, 6, 9

    var min = Math.min(...list);

    console.log(min);

    // 应用:
    // (1) 数组的浅复制   
    var list = [1, 4, 7, 2, 5, 8, 3, 6, 9];
    var arr = [...list]; // [1, 4, 7, 2, 5, 8, 3, 6, 9]
    console.log(arr);

    // (2) 数组合并  
    var arr = [1, 2, 3, 4];
    var brr = [4, 5, 6];

    var crr = [...arr, ...brr]; // [1,2,3,4,4,5,6]
    var crr = [...new Set(crr)];
    console.log(crr);

    // 交集
    // var crr = brr.filter(v => arr.includes(v));
    // console.log(crr);

    // (3) 伪数组转真数组
    var liList = document.querySelectorAll("li");

    var list = Array.from(liList);
    console.log(list);
    var list = [...liList];
    console.log(list);


    // (4) 展开字符串  => 得到逗号分隔的单个字符
    var str = "hello";
    console.log(...str);








</script>

</html>